home *** CD-ROM | disk | FTP | other *** search
- PROGRAM ReadDemo;
- USES
- CRT,
- AtSayGet,
- BlueBag,
- ReadASG;
-
- TYPE
- Info=RECORD
- Address,
- City : STRING[20];
- Phone : STRING[14];
- CASE Business : BOOLEAN OF
- False:(First : STRING[17];
- Mid : CHAR;
- Last : STRING[17]);
- True: (Name : STRING[26];
- Years : WORD;
- PorL : REAL;
- GorL : INTEGER);
- END; {variable record}
-
- VAR
- CA : ARRAY[1..5,1..5] OF WORD;
- AddInfo,
- Cont,
- More : Boolean;
- InfoFile:FILE OF Info;
- A1,A2,
- C1,C2 : WORD;
- InfoRec : Info;
-
- PROCEDURE BlankInfo;
- BEGIN
- FillChar(InfoRec,SizeOf(InfoRec),0); InfoRec.Phone:='( ) - ';
- END;
-
- PROCEDURE Init;
- {initialize 3 pages of ASG procs, assign & open data file, init vars}
- BEGIN
- MakeASGHeapPage(1,6); {Page 1 has 6 fields t/b filled}
- {set up ASG attributes}
- OrgAttr:=7; SayAttr:=7; GetAttr:=113; EndAttr:=15;
- WITH InfoRec DO
- BEGIN
- AddASGSL(1, 5,4,'First ',@First,15);
- AddASGCP(1, 5,5,'Initial ',@Mid,'A');
- AddASGSL(1, 5,6,'Last ',@Last,15);
- AddASGSL(1,50,6,'Address ',@Address,20);
- AddASGSL(1,50,8,'City ',@City,20);
- AddASGSP(1, 5,9,'Phone ',@Phone,'(999) 999-9999');
- END;
- MakeASGHeapPage(2,4); {Page 2 has 4 fields t/b filled}
- WITH InfoRec DO
- BEGIN
- AddASGSL(2, 5,6,'Name ',@Name,25);
- AddASGSL(2,50,6,'Address',@Address,20);
- AddASGSL(2,50,8,'City ',@City,20);
- AddASGSP(2, 5,9,'Phone ',@Phone,'(999) 999-9999');
- END;
- MakeASGHeapPage(3,3); {Page 3 has 3 fields t/b filled}
- {set up new ASG attributes}
- OrgAttr:=71; SayAttr:=71; GetAttr:=112; EndAttr:=79;
- WITH InfoRec DO
- BEGIN
- AddASGW (3,2,2,'Years in business.......',@Years,2);
- AddASGR (3,2,3,'Profit/Loss this year $',@PorL,10,2);
- AddASGI (3,2,4,'Gain/Loss of employees..',@GorL,4);
- END;
- TextAttr:=7; OrgAttr:=7; SayAttr:=7; GetAttr:=113;
- AddInfo:=False; Cont:=True; More:=True; FillChar(CA,SizeOf(CA),0);
- Assign(InfoFile,'READDEMO.TST');
- IF OnFile('READDEMO.TST') THEN RESET(InfoFile) ELSE
- BEGIN
- REWRITE(InfoFile); AddInfo:=True;
- END;
- END;
-
- BEGIN
- Init;
- REPEAT
- ClrScr;
- AtSay(5,1,'The full screen can be edited using cursor & tab keys.');
- IF NOT AddInfo THEN
- BEGIN {editing a file record}
- BlankInfo; READ(InfoFile,InfoRec);
- IF EOF(InfoFile) THEN AddInfo:=True;
- SEEK(InfoFile,FilePos(InfoFile)-1);
- END
- ELSE
- BEGIN
- BlankInfo;
- AtSayGetBoolean(5,3,'Adding a business record?',InfoRec.Business);
- END;
- IF InfoRec.Business THEN
- BEGIN
- ReadPage(2);
- OpenWindow(20,5,60,11,White,Red,1,' FINANCIAL INFORMATION ');
- ReadPage(3);
- CloseWindow; {financial information}
- SayAttr:=7; OrgAttr:=7;
- END
- ELSE ReadPage(1);
- WRITE(InfoFile,InfoRec);
- IF AddInfo THEN AtSayGetBoolean(2,24,'Add a record?',More)
- ELSE AtSayGetBoolean(2,24,'Edit next record?',More);
- IF NOT More THEN
- BEGIN
- CLOSE(InfoFile); Cont:=False;
- END;
- UNTIL NOT Cont;
-
- {notice how a page is reused and dynamicaly re-built in the following code}
- FOR C1:=3 DOWNTO 1 DO FreeASGHeapPage(C1);
- A1:=0; A2:=0; C1:=0; C2:=0; FillChar(CA,SizeOf(CA),0);
- ClrScr;
- WRITELN('The following demonstrates how to reuse an ASG Page. It also gives an example');
- WRITELN('of how to add fields to a page at runtime depending upon variable criteria.');
- {re-set ASG attributes}
- OrgAttr:=7; SayAttr:=7; GetAttr:=113; EndAttr:=15;
- AtSayGetWordRange(1,4,'Enter a number of columns from 2 to 5:',C2,1,2,5);
- AtSayGetWordRange(1,5,'Enter a number of rows from 2 to 5 :',C1,1,2,5);
- MakeASGHeapPage(1,C1*C2); {you will add Rows*columns of fields to the page}
- FOR A1:=1 TO C1 DO FOR A2:=1 TO C2 DO
- IF A2=1 THEN AddASGW(1,1,A1+9,'Enter numbers',@CA[A1,A2],2)
- ELSE AddASGW(1,((A2-1)*10+15),A1+9,'',@CA[A1,A2],2);
- AtSay(15,8,'The screen below can be edited using cursor & tab keys.');
- ReadPage(1);
- FreeASGHeapPage(1); {this isn't really necessary as ReadASG frees all pages
- as part of its exit code}
- AtSay(15,24,'Read ME.2');
- END.